/**
 * COPYRIGHT NOTICE Copyright (C) 2017, Buffalo Robot Tech.co, Ltd All rights
 * reserved.
 *
 * @file cubic_spline.h
 * @brief      This is the header file of cubic_spline.c
 *
 * @author     chauby 
 * @email    chaubyZou@163.com
 * @date       Dec.22, 2017
 * @version    Rehab v1.0.0.0
 */
#ifndef __CUBIC_SPLINE_H__
#define __CUBIC_SPLINE_H__

#define MAX_PVT_POINT_NUM 64

typedef struct
{
    float position;
    float velocity;
    float time;
}PVTPoint;

typedef struct
{
    float a; ///< 3 order's params of polynomial function
    float b; ///< 2 order's params of polynomial function
    float c; ///< 1 order's params of polynomial function
    float d; ///< 0 order's params of polynomial function
}PVTPolynomialParam;

typedef struct
{
    char name[32];
    unsigned int pvt_point_num;
    PVTPoint pvt_point_queue[MAX_PVT_POINT_NUM];
    PVTPolynomialParam pvt_param_queue[MAX_PVT_POINT_NUM];
}CubicSpline;

void initializeCubicSpline(CubicSpline *p_cubic_spline, const char name[32]);
void setCubicSplineGivenPointQueue(CubicSpline *p_cubic_spline, const PVTPoint *pvt_point_queue, const unsigned int pvt_point_num);
PVTPolynomialParam generateSplineTrajectoryWithTwoPoints(PVTPoint start_point, PVTPoint end_point);
void addPointToCubicSplineQueue(CubicSpline *p_cubic_spline, const PVTPoint new_pvt_point);
unsigned int generateCubicSplineTrajectory(CubicSpline *p_cubic_spline);
PVTPoint getCubicSplineValue(CubicSpline *p_cubic_spline, const float time);
void clearPVTPointQueue(CubicSpline *p_cubic_spline);
void showCubicSplineQueue(CubicSpline *p_cubic_spline);

#endif
